﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace shopform
{
    public partial class NewCompanyReferentForm : Form
    {
        public NewCompanyReferentForm()
        {
            InitializeComponent();
        }

        private void ButtonSearchCompany_Click(object sender, EventArgs e)
        {
            try
            {
                String selectedCompany;
                CompanyIDSelectorForm aCompanyIDSelector = new CompanyIDSelectorForm();
                aCompanyIDSelector.ShowDialog();
                selectedCompany = aCompanyIDSelector.getSelectedCompanyID();
                aCompanyIDSelector.Dispose();

                if (selectedCompany != "none")
                {
                    this.TBCompanyID.Text = selectedCompany;    
                }
           
            }
            catch(Exception ex)
            {
                MessageBox.Show("Hiba\n" + ex.Message);
            }
        }

        private void ButtonInsert_Click(object sender, EventArgs e)
        {
            try
            {
                CompanyReferent aCompanyReferent = new CompanyReferent();

                aCompanyReferent.CompanyID = this.TBCompanyID.Text;
                aCompanyReferent.CompanyReferentMail = this.TBCompRefMail.Text;
                aCompanyReferent.CompanyReferentName = this.TBCompRefName.Text;
                aCompanyReferent.CompanyReferentPhoneNr = this.TBCompRefPhone.Text;

                aCompanyReferent.insertCompanyReferent();
                MessageBox.Show("Kapcsolattarto beszurva!");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Hiba\n" + ex.Message);
            }
        }

        private void ButtonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
